package Controller;
import Model.*;


/**
 * Write a description of class CDSamlingCtr here.
 * 
 * @author (Ricki Jensen) 
 * @version (30.10.2010)
 */
public class CDSamlingCtr
{

    private CDSamling cdSamling;
        
    public CDSamlingCtr()
    {
        cdSamling = CDSamling.getInstance();        
    }
    
    public void opretCD(int nr, String titel) {
        
        cdSamling.createCD(nr, titel);
    }
    
    private CD findCD(String titel) {
        //print all information
        CD cd = cdSamling.findCD(titel);
        return cd;
    }
    
    public void printCD(String titel) {
      CD cd = findCD(titel);
      
      if (cd != null)
        cd.printInfo();
    }
    
    public void writeToFile() {
       try { 
        cdSamling.writeToFile("C://CDSamling.dat");
       }
       catch (Exception e) {
           System.out.println(e.toString());
       }
    }
    
    public void readFromFile() {
        try {
            cdSamling.readFromFile("C://CDSamling.dat");
        }
        catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}


